Yes, you can use any scripting language to create PagerDuty Incidents via the REST API directly or via the Events API via an event/alert.
A quick tip - visit the REST API documentation for “Create an Incident” here: https://developer.pagerduty.com/api-reference/b3A6Mjc0ODE0MA-create-an-incident
Look to the middle right side of the page for the “Request Example” and select Python (or other languages) and you’ll get a simple example to use.
Full example:
import requests
url = "https://api.pagerduty.com/incidents"
payload = {"incident": {
"type": "incident",
"title": "The server is on fire.",
"service": {
"id": "PWIXJZS",
"type": "service_reference"
},
"priority": {
"id": "P53ZZH5",
"type": "priority_reference"
},
"urgency": "high",
"incident_key": "baf7cf21b1da41b4b0221008339ff357",
"body": {
"type": "incident_body",
"details": "A disk is getting full on this machine. You should investigate what is causing the disk to fill, and ensure that there is an automated process in place for ensuring data is rotated (eg. logs should have logrotate around them). If data is expected to stay on this disk forever, you should start planning to scale up to a larger disk."
},
"escalation_policy": {
"id": "PT20YPA",
"type": "escalation_policy_reference"
}
}}
headers = {
"Content-Type": "application/json",
"Accept": "application/vnd.pagerduty+json;version=2",
"From": "",
"Authorization": "Token token=YOUR TOKEN HERE"
}
response = requests.request("POST", url, json=payload, headers=headers)
print(response.text)
For python, I also recommend using the PDPYRAS library here: https://pagerduty.github.io/pdpyras/